package org.jivesoftware.smackx.packet;

import java.util.Date;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.StringUtils;

public class StreamInitiation extends IQ
{
  private String id;
  private String mimeType;
  private File file;
  private Feature featureNegotiation;

  public void setSesssionID(String paramString)
  {
    this.id = paramString;
  }

  public String getSessionID()
  {
    return this.id;
  }

  public void setMimeType(String paramString)
  {
    this.mimeType = paramString;
  }

  public String getMimeType()
  {
    return this.mimeType;
  }

  public void setFile(File paramFile)
  {
    this.file = paramFile;
  }

  public File getFile()
  {
    return this.file;
  }

  public void setFeatureNegotiationForm(DataForm paramDataForm)
  {
    this.featureNegotiation = new Feature(paramDataForm);
  }

  public DataForm getFeatureNegotiationForm()
  {
    return this.featureNegotiation.getData();
  }

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    if (getType().equals(IQ.Type.SET))
    {
      localStringBuilder.append("<si xmlns=\"http://jabber.org/protocol/si\" ");
      if (getSessionID() != null)
        localStringBuilder.append("id=\"").append(getSessionID()).append("\" ");
      if (getMimeType() != null)
        localStringBuilder.append("mime-type=\"").append(getMimeType()).append("\" ");
      localStringBuilder.append("profile=\"http://jabber.org/protocol/si/profile/file-transfer\">");
      String str = this.file.toXML();
      if (str != null)
        localStringBuilder.append(str);
    }
    else if (getType().equals(IQ.Type.RESULT))
    {
      localStringBuilder.append("<si xmlns=\"http://jabber.org/protocol/si\">");
    }
    else
    {
      throw new IllegalArgumentException("IQ Type not understood");
    }
    if (this.featureNegotiation != null)
      localStringBuilder.append(this.featureNegotiation.toXML());
    localStringBuilder.append("</si>");
    return localStringBuilder.toString();
  }

  public class Feature
    implements PacketExtension
  {
    private final DataForm data;

    public Feature(DataForm arg2)
    {
      Object localObject;
      this.data = localObject;
    }

    public DataForm getData()
    {
      return this.data;
    }

    public String getNamespace()
    {
      return "http://jabber.org/protocol/feature-neg";
    }

    public String getElementName()
    {
      return "feature";
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<feature xmlns=\"http://jabber.org/protocol/feature-neg\">");
      localStringBuilder.append(this.data.toXML());
      localStringBuilder.append("</feature>");
      return localStringBuilder.toString();
    }
  }

  public static class File
    implements PacketExtension
  {
    private final String name;
    private final long size;
    private String hash;
    private Date date;
    private String desc;
    private boolean isRanged;

    public File(String paramString, long paramLong)
    {
      if (paramString == null)
        throw new NullPointerException("name cannot be null");
      this.name = paramString;
      this.size = paramLong;
    }

    public String getName()
    {
      return this.name;
    }

    public long getSize()
    {
      return this.size;
    }

    public void setHash(String paramString)
    {
      this.hash = paramString;
    }

    public String getHash()
    {
      return this.hash;
    }

    public void setDate(Date paramDate)
    {
      this.date = paramDate;
    }

    public Date getDate()
    {
      return this.date;
    }

    public void setDesc(String paramString)
    {
      this.desc = paramString;
    }

    public String getDesc()
    {
      return this.desc;
    }

    public void setRanged(boolean paramBoolean)
    {
      this.isRanged = paramBoolean;
    }

    public boolean isRanged()
    {
      return this.isRanged;
    }

    public String getElementName()
    {
      return "file";
    }

    public String getNamespace()
    {
      return "http://jabber.org/protocol/si/profile/file-transfer";
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append("\" ");
      if (getName() != null)
        localStringBuilder.append("name=\"").append(StringUtils.escapeForXML(getName())).append("\" ");
      if (getSize() > 0L)
        localStringBuilder.append("size=\"").append(getSize()).append("\" ");
      if (getDate() != null)
        localStringBuilder.append("date=\"").append(StringUtils.formatXEP0082Date(this.date)).append("\" ");
      if (getHash() != null)
        localStringBuilder.append("hash=\"").append(getHash()).append("\" ");
      if (((this.desc != null) && (this.desc.length() > 0)) || (this.isRanged))
      {
        localStringBuilder.append(">");
        if ((getDesc() != null) && (this.desc.length() > 0))
          localStringBuilder.append("<desc>").append(StringUtils.escapeForXML(getDesc())).append("</desc>");
        if (isRanged())
          localStringBuilder.append("<range/>");
        localStringBuilder.append("</").append(getElementName()).append(">");
      }
      else
      {
        localStringBuilder.append("/>");
      }
      return localStringBuilder.toString();
    }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smackx.packet.StreamInitiation
 * JD-Core Version:    0.6.1
 */